NSArray *segmentedArray = [[NSArray alloc]initWithObjects:@"热门",@"广场",@"关注",nil];

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]initWithItems:segmentedArray];
segmentedControl.frame =CGRectMake(0.0f, 0.0f, 150.0f, 30.0f);
[segmentedControl addTarget:self action:@selector(SelectbuttonAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.layer.borderWidth = 0.0;
segmentedControl.selectedSegmentIndex=0;
segmentedControl.tintColor = [UIColor colorWithRed:0.69f green:0.75f blue:0.87f alpha:1.00f];
segmentedControl.backgroundColor = [UIColor clearColor];
self.navigationItem.titleView = segmentedControl;

-(void)SelectbuttonAction:(UISegmentedControl *)seg{

NSInteger Index = seg.selectedSegmentIndex;
switch (Index) {
        
    case 0:

        break;
        
    case 1:
        
        
        break;
        
    case 2:
        
        
        break;
        
        
    default:
        
        break;
        
}

}


Eidesen
427 声望16 粉丝

专注iOS,Swift开发,总结了一下自己项目中遇到的问题,及解决方案。欢迎小伙伴讨论和多多指教--->记得顺手点个关注额(⊙o⊙)…。


下一篇 »
Emoji检测